home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5374 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  986 b 

  1. Path: dragon.cs.hku.hk!kwho
  2. From: kwho@csd.hku.hk (Lord Hermes)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question on char to int and back
  5. Date: 4 Feb 1996 03:30:16 GMT
  6. Organization: Department of Computer Science, The University of Hong Kong
  7. Message-ID: <4f1988$dnk@ns.cs.hku.hk>
  8. References: <miller.1.00C350A1@crosslink.net>
  9. NNTP-Posting-Host: dragon.cs.hku.hk
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. : This might seem like a trivial question but I would like to know how I can go
  13. : from reading in a char, placing it in a stack of int (ie)
  14. :         char c; 
  15. :         c = cin.get()
  16. :         push(s,c);
  17. :         now if the char was a '+', it would be entered into the stack as 43.
  18. :         I know that a cout.put(c) will output it as a character but if I want 
  19. :         to pop it from the stack and act on it as a character how do I
  20. :         convert it back to a character?
  21.     Can it be "a = (char) (c && 0x00ff)"? (a is the character you
  22. want; c is the integer you pop from the stack)
  23.